package com.fyzk.activity.lottery.recommend_order;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.tyjc.lottery.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanxs11 on 17/7/4.
 * 晒单——大神Adapter
 */

public class GodAdapter extends BaseAdapter {

    private Context context;
    private List<GodBean> infos = new ArrayList<>();

    public GodAdapter(Context context, List<GodBean> infos) {
        this.context = context;
        this.infos = infos;
    }

    @Override
    public int getCount() {
        return infos.size();
    }

    @Override
    public Object getItem(int position) {
        return infos.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        GodBean info = infos.get(position);
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.adapter_god, null);
            holder.userName_tv = (TextView) convertView.findViewById(R.id.god_item_username);
            holder.time_tv = (TextView) convertView.findViewById(R.id.god_item_time);
            holder.hittatio_tv = (TextView) convertView.findViewById(R.id.god_item_hittatio_tv);
            holder.profitratio_tv = (TextView) convertView.findViewById(R.id.god_item_profitratio_tv);
            holder.followCount_tv = (TextView) convertView.findViewById(R.id.god_item_followcount_tv);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.userName_tv.setText(info.getUserName());
        holder.hittatio_tv.setText("命中率："+info.getHitRatio()+"%");
        holder.profitratio_tv.setText("盈利率："+info.getProfitRatio()+"%");
        holder.followCount_tv.setText("被跟单数："+info.getFollowCount());
        return convertView;
    }

    public void setInfos(List<GodBean> infos) {
        this.infos = infos;
        this.notifyDataSetChanged();
    }

    class ViewHolder {
        TextView userName_tv;
        TextView time_tv;
        TextView hittatio_tv;
        TextView profitratio_tv;
        TextView followCount_tv;

    }
}
